<template>
  <a-spin :spinning="confirmLoading">
    <div class="top-row">
      <a-form-item :colon="false" label="设备名称">
        <!--        {{ model.name }}-->
        {{model.shebeiname}}
      </a-form-item>
      <a-form-item :colon="false" label="设备编号">
        {{ model.shebeibianhao }}
      </a-form-item>
      <a-form-item :colon="false" label="计划名称">
        {{ model.name }}
      </a-form-item>
      <a-form-item :colon="false" label="计划编号">
        {{ model.bianhao }}
      </a-form-item>
      <a-form-item :colon="false" label="保养层级">
        {{ model.cengji_dictText }}
      </a-form-item>
      <a-form-item :colon="false" label="保养方式">
        {{ model.fangshi_dictText }}
      </a-form-item>
      <a-form-item :colon="false" label="间隔天数">
        {{ model.jiangeshichang }}
      </a-form-item>
    </div>
    <j-form-container :disabled="true">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail" style="padding-top: 15px;">
        <a-row>
          <a-col :span="12">
            <a-form-model-item  label="执行人"  style="display: block; margin-bottom: 10px;" prop="fuzeren">
              <a-input v-model="model.fuzeren_dictText" placeholder="确定后自动生成"/>
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item  label="保养时间"  style="display: block; margin-bottom: 10px;" prop="zhixingshijian">
              <j-date
                placeholder="确定后自动生成"
                v-model="model.zhixingshijian"
                :show-time="true"
                date-format="YYYY-MM-DD "
                style="width: 100%"
              />
            </a-form-model-item>
          </a-col>
        </a-row>
        <a-row>
          <a-col :span="12">
            <a-form-model-item  label="保养说明"  style="display: block; margin-bottom: 10px;" prop="beizhu">
              <a-textarea v-model="model.beizhu" placeholder="请输入保养说明" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
    <j-form-container :disabled="formDisabled">
      <a-form-model ref="form" :model="model" :rules="validatorRules" slot="detail" style="padding-top: 15px;">
        <a-row>
          <a-col :span="12">
            <a-form-model-item  label="验收人"  style="display: block; margin-bottom: 10px;" prop="checkBy">
              <a-input v-model="model.checkBy" placeholder="请输入验收人" />
            </a-form-model-item>
          </a-col>
          <a-col :span="12">
            <a-form-model-item  label="验收时间"  style="display: block; margin-bottom: 10px;" >
            <j-date
              placeholder="请选择验收时间"
              v-model="model.checkTime"
              :show-time="true"
              date-format="YYYY-MM-DD HH:mm:ss"
              style="width: 100%"
            />
            </a-form-model-item>
          </a-col>
        </a-row>

        <a-row>
          <a-col :span="12">
            <a-form-model-item  label="验收建议"  style="display: block; margin-bottom: 10px;" prop="checkInfo">
              <a-textarea v-model="model.checkInfo" placeholder="请输入验收建议" />
            </a-form-model-item>
          </a-col>
        </a-row>
      </a-form-model>
    </j-form-container>
  </a-spin>
</template>

<script>

import { httpAction, getAction } from '@/api/manage'
import { validateDuplicateValue } from '@/utils/util'

export default {
  name: 'GdBaoyangTaskCheckForm',
  components: {
  },
  props: {
    //表单禁用
    disabled: {
      type: Boolean,
      default: false,
      required: false
    }
  },
  data() {
    return {
      model: {
      },
      labelCol: {
        xs: { span: 24 },
        sm: { span: 5 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
      confirmLoading: false,
      validatorRules: {
      },
      url: {
        add: "/gongdan/gdBaoyangRenwu/add",
        edit: "/gongdan/gdBaoyangRenwu/check/edit",
        queryById: "/gongdan/gdBaoyangRenwu/queryById"
      },
      dataSource: []
    }
  },
  computed: {
    formDisabled() {
      return this.disabled
    },
  },
  created() {
    //备份model原始值
    this.modelDefault = JSON.parse(JSON.stringify(this.model));
  },
  methods: {
    handleChange(e) {
      // const value = e.target.value
      // this.value = value
    },
    add() {
      this.edit(this.modelDefault);
    },
    deal(record) {
      this.model = Object.assign({}, record)
      this.disabled = false
    },
    edit(record) {
      this.model = Object.assign({}, record);
      this.visible = true;
    },
    submitForm() {
      const that = this;
      // 触发表单验证
      this.$refs.form.validate(valid => {
        if (valid) {
          that.confirmLoading = true;
          let httpurl = '';
          let method = '';
          if (!this.model.id) {
            httpurl += this.url.add;
            method = 'post';
          } else {
            httpurl += this.url.edit;
            method = 'put';
          }
          httpAction(httpurl, this.model, method).then((res) => {
            if (res.success) {
              that.$message.success(res.message);
              that.$emit('ok');
            } else {
              that.$message.warning(res.message);
            }
          }).finally(() => {
            that.confirmLoading = false;
          })
        }
      })
    },
  }
}
</script>
<style scoped>
.top-row {
  background: #F4F5F7;
  padding: 12px 24px;
  width: 100%;
  display: flex;
  justify-content: space-between;
}

.top-row /deep/ .ant-form-item {
  margin-bottom: 0;
  color: #6B778C
}

.top-row /deep/ .ant-form-item-label {
  line-height: 1;
}

.top-row /deep/ .ant-form-item-control {
  line-height: 1;
  margin-top: 10px;
}

.top-row /deep/ .ant-form-item-label>label {
  color: #6B778C
}

.basic-info-box,
.system-info-box {
  padding: 20px 0;
}

.basic-info-box /deep/ .ant-form-item,
.system-info-box /deep/ .ant-form-item {
  margin-bottom: 20px;
}

.basic-info-box /deep/ .ant-form-item-label>label {
  color: #172B4D;
}

.ene-w-h-d /deep/ .ant-collapse-borderless>.ant-collapse-item {
  border: none;
}

.ene-w-h-d /deep/ .ant-collapse-header {
  background: #F4F5F7;
}

.ene-w-h-d /deep/ .ant-collapse {
  background: transparent;
}

.ene-w-h-d /deep/ .ant-input[disabled] {
  background: #ebecf0
}

.ene-w-h-d /deep/ .ant-collapse-content>.ant-collapse-content-box {
  padding: 0
}
</style>